﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Libs.HR;

public partial class Pages_Hr_Education_Edit : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        AppUtils.CheckLogin();
        Title = Title + " - Cập nhật loại hợp đồng";
        if (!IsPostBack)
        {
            btDelete.Attributes.Add("onclick", "return confirm('Bạn có đồng ý xóa?');");
            init();
        }
    }

    private void init()
    {
        var _Education = new Education() { EducationID = AppUtils.Request("id") };
        _Education = _Education.Get();
        if (_Education == null) Response.Redirect(Constant.ADMIN_PATH + Resources.Url.EducationList);

        txtName.Text = _Education.Name;
        txtOrder.Text = _Education.Order.ToString();
    }

    protected void btUpdate_Click(object sender, EventArgs e)
    {
        var _Education = new Education() { EducationID = AppUtils.Request("id") };
        _Education = _Education.Get();
        _Education.Name = txtName.Text.Trim();
        _Education.Order = Convert.ToInt32(txtOrder.Text);
        _Education.Update();

        Response.Redirect(Constant.ADMIN_PATH + Resources.Url.EducationList);
    }

    protected void btDelete_Click(object sender, EventArgs e)
    {
        Education _Education = new Education() { EducationID = AppUtils.Request("id") };
        _Education.Delete();
        Response.Redirect(Constant.ADMIN_PATH + Resources.Url.EducationList);
    }

    protected void btCancel_Click(object sender, EventArgs e)
    {
        Response.Redirect(Constant.ADMIN_PATH + Resources.Url.EducationList);
    }
}
